extend layout
block main
	#setting
		.form-horizontal
			.form-group
				.col-lg-offset-2.col-lg-10
					h4 文章抓取key
			.form-group
				label.col-lg-2.control-label uin
				.col-lg-10
					input.form-control#uin
			.form-group
				label.col-lg-2.control-label key
				.col-lg-10
					input.form-control#key
			.form-group
				.col-lg-offset-2.col-lg-10
					button.btn.btn-default(type="button",onclick="keySubmit()") 提交

		hr
		.form-horizontal
			.form-group
				.col-lg-offset-2.col-lg-10
					h4 网页版登录cookie(帐号头图抓取时使用)
			.form-group
				label.col-lg-2.control-label cookie
				.col-lg-10
					input.form-control#cookie
			.form-group
				.col-lg-offset-2.col-lg-10
					button.btn.btn-default(type="button",onclick="cookieSubmit()") 提交

		hr
		#count-status.well
		button.btn.btn-default(onclick="updateCount()") 更新文章统计
	script
		var cookieSubmit = function(){
			$('#loading').modal('show');
			$.ajax({
				url:'/admin/cookie',
				type:'post',
				data:{
					cookie:$('#cookie').val()
				},
				success:function(data){
					$('#loading').modal('hide');

				}
			});
			return false;
		}

		var keySubmit = function(){
			$.ajax({
				url:'/admin/key',
				type:'post',
				data:{
					uin:$('#uin').val(),
					key:$('#key').val()
				},
				success:function(data){
					$('#loading').modal('hide');
				}
			});
			return false;
		}
		var updateCount = function(){
			$('#loading').modal('show');
			$.ajax({
				url:'count/update',
				success:function(){
					$('#loading').modal('hide');
					loadCount()
				}
			})
		}

		var loadCount = function(){
			$('#loading').modal('show');
			$.ajax({
				url:'articles/count',
				success:function(data){
					$('#loading').modal('hide');
					$('#count-status').text('一共'+data.articles_count+'篇通过'+data.approved_count+'篇')
				}
			})
		}
		loadCount()
